<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #field {
        width: 1000px;
        height: 500px;
        border: 3px grey solid;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
      }

      #box {
        width: 50px;
        height: 50px;
        background-color: red;
        position: relative;
        animation: box 2s infinite;
        animation-duration: alternate;
      }

      @keyframes box {
        0% {
          background-color: red;
          left: 0px;
          top: 0px;
        }

        25% {
          background-color: yellow;
          left: 333px;
          top: 450px;
        }

        50% {
          background-color: blue;
          left: 500px;
          top: 0px;
        }

        75% {
          background-color: green;
          left: 666px;
          top: 450px;
        }

        100% {
          background-color: red;
          left: 950px;
          top: 0px;
        }
      }
    </style>
  </head>
  <body>
    <div id="field">
      <div id="box"></div>
    </div>
  </body>
</html>
